import Vue from 'vue'
import Router from 'vue-router'


// add by houlu  bug fix :
// Uncaught(in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/about" or "/home".
const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const originalPush2 = Router.prototype.replace

Router.prototype.replace = function replace(location) {
  return originalPush2.call(this, location).catch(err => err)
}


Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'Home',
      component : ()=> import('@/views/home/Home')
    },
    {
      path: '/category',
      name: 'Category',
      component : ()=> import('@/views/category/Category')
    },
    {
      path: '/cart',
      name: 'Cart',
      component : ()=> import('@/views/cart/Cart')
    },
    {
      path: '/profile',
      name: 'Profile',
      component : ()=> import('@/views/profile/Profile')
    }
  ],
  mode : 'history'
})
